///\todo upgrade

//////////////////////////////////////////////////////////////////////////////////
//                                                                              //
//  This file is part of the buola project (https://code.google.com/p/buola/).  //
//                                                                              //
//  Copyright(c) 2007-2012 Xavi Gratal                                          //
//  gratal AT gmail DOT com                                                     //
//                                                                              //
//  Buola is free software: you can redistribute it and/or modify               //
//  it under the terms of the GNU General Public License as published by        //
//  the Free Software Foundation, either version 3 of the License, or           //
//  (at your option) any later version.                                         //
//                                                                              //
//  Buola is distributed in the hope that it will be useful,                    //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of              //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               //
//  GNU General Public License for more details.                                //
//                                                                              //
//  You should have received a copy of the GNU General Public License           //
//  along with buola.  If not, see <http://www.gnu.org/licenses/>.              //
//                                                                              //
//////////////////////////////////////////////////////////////////////////////////

#ifndef _BUOLA_IO_CFOLDER_H_
#define _BUOLA_IO_CFOLDER_H_

#include <buola/io/cfile.h>

#include <unordered_set>
#include <unordered_map>

namespace buola { namespace io {

///\addtogroup filesystem
///@{

////////////////////////////////////////////////////////////////////////////

/// folder

///
///
///
////////////////////////////////////////////////////////////////////////////

class CFolder : public CFile
{
protected:
    //! information on a mounted filesystem
    class SMountInfo
    {
    public:
        bool mMounted;
        std::string mDevice;
        std::string mType;
        std::string mOptions;
        std::string mMode;
    };

public:
//! \name constructor and destructor
//@{
    CFolder() {}
    
    CFolder(const CURI &pURI)
        : CFile(pURI)
    {}
    
    CFolder(const CFolder&)=default;
    CFolder(CFolder&&)=default;
    CFolder& operator=(const CFolder&)=default;
    CFolder& operator=(CFolder&&)=default;
//@}

public:
//! \name interface to folder contents
//@{
    std::vector<CFile> GetChildren(const PFileFilter &pFilter=nullptr) const
    {
        return mImpl->GetChildren(pFilter);
    }
    
    std::vector<std::string> GetChildrenNames(const PFileFilter &pFilter=nullptr) const
    {
        return mImpl->GetChildrenNames(pFilter);
    }

    std::unordered_set<std::string> GetChildrenSet(const PFileFilter &pFilter=nullptr) const
    {
        return mImpl->GetChildrenSet(pFilter);
    }
    
    std::vector<CURI> GetChildrenURIs(const PFileFilter &pFilter=nullptr) const
    {
        return mImpl->GetChildrenURIs(pFilter);
    }
    
    bool HasChildren(const PFileFilter &pFilter=nullptr) const
    {
        return mImpl->HasChildren(pFilter);
    }
//@}

//! \name mounting filesysems
//@{
    void Mount(){   throw XInvalid(I18N("Not mountable"));        }
    void UnMount()          {   throw XInvalid(I18N("Not mountable"));        }

    bool IsMountPoint()     {   return false;   }
    bool IsMounted()        {   return false;   }
//@}

//! \name monitor for changes
//@{
    //! starts watching the folder for changes
    void StartMonitor()     {}
    //! stops watching the folder for changes
    void StopMonitor()      {}
//@}

//! \name events
//@{
    UEvent<void(CURI)> eChanged;
    UEvent<void(CURI)> eCreated;
    UEvent<void(CURI)> eDeleted;
//@}
};

///@}

/*namespace io*/ } /*namespace buola*/ }

#endif
